import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-10-23
 * Time: 17:45
 */
//servlet注解 当req请求到这个路径时，就回调用doGet方法
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    //只在首次收到请求时初始化一次
    @Override
    public void init() throws ServletException {
        System.out.println("Init");
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doGet(req, resp); 这个父类接口返回一个错误页面，没有实际价值
        System.out.println("hello world!");
        resp.getWriter().write("hello world");
    }
}
